package com.miyake.loveviewweb.shared.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.datastore.Key;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

@Model(schemaVersion = 1)
public class UserModel implements Serializable {
    
    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;

    /**
     * Returns the key.
     *
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     *
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     *
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     *
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        UserModel other = (UserModel) obj;
        if (key == null) {
            if (other.key != null) {
                return false;
            }
        } else if (!key.equals(other.key)) {
            return false;
        }
        return true;
    }
    
    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public List<Key> getMyPlugins() {
        return myPlugins;
    }

    public void setMyPlugins(List<Key> myPlugins) {
        this.myPlugins = myPlugins;
    }


    /**
     * @return the selectedItem
     */
    public Key getSelectedItem() {
        return selectedItem;
    }

    /**
     * @param selectedItem the selectedItem to set
     */
    public void setSelectedItem(Key selectedItem) {
        this.selectedItem = selectedItem;
    }


    /**
     * @return the imageUrl
     */
    public String getImageUrl() {
        return imageUrl;
    }

    /**
     * @param imageUrl the imageUrl to set
     */
    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }


    /**
     * @return the image
     */
    public Key getImage() {
        return image;
    }

    /**
     * @param image the image to set
     */
    public void setImage(Key image) {
        this.image = image;
    }


    /**
     * @return the myFriends
     */
    public List<Key> getMyFriends() {
        return myFriends;
    }

    /**
     * @param myFriends the myFriends to set
     */
    public void setMyFriends(List<Key> myFriends) {
        this.myFriends = myFriends;
    }


    private String email;
    private String firstName;
    private String lastName;
    private String userID;

    private Key selectedItem;
    
    private List<Key> myPlugins = new ArrayList<Key>();
    private List<Key> myFriends = new ArrayList<Key>();
    
    @Attribute(persistent=false)
    private String imageUrl;
    
    private Key image;
}
